<script setup lang="ts">
// import { useUserStore } from '@/stores/modules/user'
import { useUserStore } from '@/stores'
import type { User } from '@/types/user'
import { instance, request } from '@/utils/request'
import { Button as VanButton } from 'vant'
import { useRoute, useRouter } from 'vue-router'
const userStore = useUserStore()

const handlelogin = async () => {
  // const res = await instance.request({
  //   url: '/login/password',
  //   method: 'post',
  //   data: {
  //     mobile: '13230000088',
  //     // password: 'abc123456'
  //     password: 'abc12345'
  //   }
  // })
  const res = await request<User>('/login/password', 'POST', {
    mobile: '13230000088',
    password: 'abc12345'
  })
  console.log(res.data)
  userStore.setUser(res.data)
  console.log('可以跳登录页了')
}
const handleGetMe = async () => {
  const res = await instance.request({
    url: '/patient/myUser'
  })
  console.log(res)
}
const router = useRouter()
const route = useRoute()
const handleGoToHome = () => {
  router.push('/')
  console.log(route.query)
}
</script>

<template>
  <div class="playground-page">
    <h1>playground</h1>
    <h2>user{{ userStore.user }}</h2>
    <!-- <van-button @click="userStore.setUser({ refreshToken: '1', token: '2' })" -->
    <van-button @click="handlelogin">login</van-button>
    <van-button @click="userStore.delUser" type="primary">logout</van-button>
    <van-button @click="handleGetMe">get me</van-button>
    <van-button @click="handleGoToHome" type="primary">跳转首页</van-button>
  </div>
</template>

<style scoped></style>
